<?php
if (!defined('APP_ID')) { die('No direct script access allowed'); }

abstract class Database_Query_Mysql {
	public function value($value, $type = null) {
		$result = "";

		$db = Database::factory();
		if (is_null($value)) {
			$result = "NULL";
		} else {
			switch ($type) {
				case 'function':
					$result = $db->escape($value);
					break;
				case 'serialize':
					$result = $db->escape(serialize($value));
					break;
				case 'integer':
					$result = intval($value);
					break;
				case 'string':
				default: 
					$result = "'" . $db->escape($value) . "'";
				
			}
		}
		
		return $result;
	}
	
	public function execute() {
		$db = Database::factory();
		return $db->query($this->compile());
	}
}
